package com.superman.domain;

import java.util.List;

public class PageBean {
	private int total;
	private int size;
	private int pageNum;
	private int end;
	private List<Product> data;
	private int bar[];
	
	public int[] getBar() {
		//将数组中所有应该出现的数字都准备好
		//定义数组的头和尾
		int start = 0;
		int stop = 0;
		if(end < 10) {
			start = 1;
			stop = end;
		}else {
			start = pageNum -5;
			stop = pageNum + 4;
			if(start < 1) {
				start = 1 ;
				stop = 10;
			}
			if(stop >= end) {
				stop = end;
				start = end - 9;
			}
		}
		//定义数组的长度
		bar = new int[stop - start+1];
		//定义一个角标
		int index = 0;
		for (int i = start; i <= stop; i++) {
			bar[index++] =  i;
		}
		return bar;
	}

	public void setBar(int[] bar) {
		this.bar = bar;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getEnd() {
		return end;
	}

	public void setEnd(int end) {
		this.end = end;
	}

	public List<Product> getData() {
		return data;
	}

	public void setData(List<Product> data) {
		this.data = data;
	}


	@Override
	public String toString() {
		return "PageBean [total=" + total + ", size=" + size + ", pageNum=" + pageNum + ", end=" + end + ", data="
				+ data + "]";
	}

}
